#ifndef __IMPACT_MGR_H__
#define __IMPACT_MGR_H__

#include "utils/singleton.h"
#include "./impactobj.h"

class ImpactMgr : public Singleton<ImpactMgr>
{
	typedef vector<ImpactObj*> ImpactObjList;
	typedef vector<ImpactObj*>::iterator ImpactObjIter;
public:
	ImpactMgr();
	~ImpactMgr();

	void RegisterImpactObj(ImpactObj* p);
	void UnRegisterImpactObj(ImpactObj* p);

	ImpactObj*  CalcImpact(Point& newPos, ImpactObj* pCalcObj, ImpactObj* pAddtionFlitObj);
	ImpactObj* CalcIntersection(ImpactObj* pCalcObj, ImpactObj* pAddtionFlitObj);

private:
	bool CheckIntersection(Point pos1, Point pos2, float minlength);

private:
	CRITICAL_SECTION m_csThreadSafe;

	//if not static will error(CRITICAL_SECTION cause)
	static ImpactObjList m_list;
};

#endif